﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.RestrictedUsage.CSharp.Syntax;
using System.Collections;
using Microsoft.RestrictedUsage.CSharp.Extensions;

namespace CSharpParser.CSharpModel
{

    public class FileCodeItemsCollector : ParseTreeVisitor, IEnumerable<ParseTreeNode>, IEnumerable
    {
        // Fields
        private readonly List<ParseTreeNode> nodes = new List<ParseTreeNode>();

        // Methods
        public FileCodeItemsCollector(ParseTreeNode node)
        {
            this.Visit(node);
        }

        public IEnumerator<ParseTreeNode> GetEnumerator()
        {
            return this.nodes.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        public override bool TraverseInteriorTree(ParseTreeNode node)
        {
            return false;
        }

        public override void VisitAttributeSectionNode(AttributeSectionNode node)
        {
            base.VisitAttributeSectionNode(node);
            this.nodes.Add(node);
        }

        public override void VisitTypeDeclarationNode(TypeDeclarationNode node)
        {
            base.VisitTypeDeclarationNode(node);
            this.nodes.Add(node);
        }
    }


}
